#ifndef INSPECTORDIALOG_H
#define INSPECTORDIALOG_H

#include <QtCore>
#include <QtGui/QDialog>
#include <QAbstractTableModel>

namespace Ui {
    class InspectorDialog;
}


class InspectorDataModel : public QAbstractTableModel
{
	Q_OBJECT

public:
	InspectorDataModel(QObject *parent = NULL) : QAbstractTableModel(parent) {}
	
	QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
	Qt::ItemFlags flags(const QModelIndex &index) const;

	int rowCount(const QModelIndex & parent = QModelIndex()) const;
	int columnCount(const QModelIndex & parent = QModelIndex()) const;
	QVariant data (const QModelIndex & index, int role = Qt::DisplayRole) const;
	bool setData(const QModelIndex &index, const QVariant &value, int role);
	void setData(const QMap<QString, QString>& data);

private:
	QList< QPair< QString, QString > > listOfPairs;
};


class InspectorDialog : public QDialog {
    Q_OBJECT
    Q_DISABLE_COPY(InspectorDialog)
public:
    explicit InspectorDialog(QWidget *parent = 0);
    virtual ~InspectorDialog();

public slots:
	void setData(const QMap<QString, QString>& data);
	
	void centerHorizontalSlider();
	void centerVerticalSlider();
	
	void setHorizontalScalingSpeed(int speed);
	void setVerticalScalingSpeed(int speed);
	
	void resetScaling();
	void updateScale();
	
	void centerHorizontalPositionSlider();
	void setHorizontalPanSpeed(int speed);
	void updatePan();
	
	void lookAtPast();
	void lookAtPresent();
	void lookAtFuture();
	
	void search();
	void focus();
	void clear();
	void moveTo();
	void previousItem() { emit moveToPrevious(); }
	void nextItem() { emit moveToNext(); }
	
	void updateInspectorData(const QMap<QString, QString>& data);
	
signals:
	void scaleChanged(float horizontal, float vertical);
	void moveChanged(float horizontal, float vertical);
	void panChanged(float angle);
	
	void dummySearch(QString threadstate);
	void focusSelection();
	void clearSelectionOrSearch();
	
	void moveToPosition(float position);
	void moveToPrevious();
	void moveToNext();
	
protected:
    virtual void changeEvent(QEvent *e);
	float getMultiplier(int speed) const { if (speed >= 0) return 1.0 + (float)speed / 600.0f; else return 1.0f / getMultiplier(-speed); }
	float getStep(int speed) const;

protected:
	float horizontalScale;
	float verticalScale;
	
	QTimer* scaleTimer;
	QTimer* panTimer;
	
	InspectorDataModel model;
	
private:
    Ui::InspectorDialog *m_ui;
};

#endif // INSPECTORDIALOG_H
